
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<jsp:include page="headerlinks.jsp" />
<div class="ui-accordion">
	<form:form action="home.htm" method="post" commandName="fbb">
		<c:set var="user" value="${fbb.userDetails}" />
		<div class="contentcell cleft">
			<div class="ui-widget ui-state-highlight" style="padding: 0.7em;">
				${user.firstName}, <fmt:message key="welcome.message.text" />
				
				<div>
					<b class="ui-menu-item"><fmt:message key="new.post.linl.pretext"/>
					<a class="ui-state-hover" href="pages/newPost.htm"><fmt:message key="new.post.link.title"/></a></b>
				</div>
			</div>
			<br>
			<div class="ui-widget-header">
				<h6 align="center">
					<fmt:message key="recent.posts.label" />
				</h6>
			</div>
			<div class="ui-widget-content">
				<c:if test="${not empty user.posts}">
					<c:forEach var="post" items="${user.posts}">
						<li><a href="pages/updatePost.htm?postId=${post.objId}">${post.postTitle}</a></li>
					</c:forEach>
				</c:if>
			</div>
			<br>
			<div class="ui-widget-header">
				<h6 align="center">
					<fmt:message key="last.login.label"/>
				</h6>
			</div>
			<div class="ui-widget-content">
				<fmt:message key="last.login.text"/>${user.lastLogin}
			</div>
		</div>
		<div class="contentcell cright">
			<div class="ui-widget-header  ui-state-default">
				<h6 align="center">
					<fmt:message key="existing.posts.label" />
				</h6>
			</div>
			<div class="ui-widget-content">
				<c:choose>
					<c:when test="${not empty user.posts}">
						<c:forEach var="prevPost" items="${user.posts}" end="4">
							<div class="ui-widget-header homepage-posttitle">
								<h6>${prevPost.postTitle}</h6>
							</div>
							<div class="ui-widget-content homepage-postcontent">
								<p>${prevPost.postContent}</p>
							</div>
						</c:forEach>
						<div class="clearingdiv"></div>
					</c:when>
					<c:otherwise>
						<div>
							<fmt:message key="no.posts.message"/>
						</div>
						<div>
							<a href="pages/newPost.htm"><fmt:message key="first.post.link.title"/></a>
						</div>
					</c:otherwise>
				</c:choose>
				
			</div>
		</div>
	</form:form>
</div>
<jsp:include page="footer.jsp"></jsp:include>